<%--
  User: spolyakov
  Date: 19.07.12
  Time: 15:37
--%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@ taglib uri="http://displaytag.sf.net" prefix="display" %>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.7.2.js"></script>

<SCRIPT type="text/javascript">
    function showSelect(ind) {
        $.ajax({
            url: '${pageContext.request.contextPath}/getCityList?country_id=' + ind,
            dataType: 'html',
            success: function(html) {
                $("#areaTd").html(html);
            }
        });
    }
</SCRIPT>

<div id="content">

    <h2><spring:message code="label.affiliates"/></h2>

    <br/>

    <div id="quickSearch" align="right">

        <spring:message code="label.search"/>:

        <br/>

        <form action="service">
            <spring:message code="label.name"/>:
            <input type="text"/> <br/>

            <spring:message code="label.country"/>:

            <select name="country_id" style="width: 146px;"
                    onChange="showSelect(this.options[this.selectedIndex].value)"
                    onclick="showSelect(this.options[this.selectedIndex].value)">

                <c:forEach items="${country}" var="country">
                    <option value="${country.id}">
                        <c:out value="${country.name}"/>
                    </option>
                </c:forEach>

            </select>

            <br/>

            <label id="areaTd">
            </label>

            <br/> <br/>

            <input type="submit" value="ok" style="width: 100px;"/>
        </form>

        <a href="#"> Расширеный поиск </a>

    </div>
    <div>

        <br/>

        Показывать по:
        <select>
            <option>5</option>
            <option>10</option>
            <option>20</option>
            <option>50</option>
        </select>

        <display:table name="carServices" id="carService" pagesize="5" class="affList"
                       requestURI="${pageContext.request.contextPath}/affiliates">

            <display:column>

                <a href="service?id=<c:out value='${carService.id}'/> " style="font-size: 24px;">
                    <c:out value='${carService.name}'/>
                </a>

                <br/>
                <spring:message code="label.address"/>:
                <c:out value='${carService.address}'/>

            </display:column>
            <display:column style="text-align: left">

                <spring:message code="label.rating"/>:
                <c:out value="${carService.rating}"/>
                <c:forEach begin="1" end="${carService.rating}">
                    <img src="img/star.png" />
                </c:forEach>

                <br/>

                <spring:message code="label.phone"/>:
                <c:out value='${carService.phone}'/>

            </display:column>
        </display:table>

    </div>
</div>